package com.ctshk.sapp.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.model.TokenUser;
import com.ctshk.rpc.system.dto.MainDataHousingTypeListDTO;
import com.ctshk.rpc.system.dto.MainDataHousingTypeQueryDTO;
import com.ctshk.rpc.system.req.MainDataHousingTypeAddReq;
import com.ctshk.rpc.system.req.MainDataHousingTypeListReq;
import com.ctshk.rpc.system.req.MainDataHousingTypeUpdateReq;
import com.ctshk.rpc.system.req.MainDataHousingTypeUpdateStatusReq;
import com.ctshk.rpc.system.service.IMainDataHousingTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-02-02
 */
@Api(value = "住房类型",tags = "住房类型")
@RestController
@RequestMapping("/main/data/housing/type")
public class MainDataHousingTypeController extends BaseController {


    @DubboReference
    private IMainDataHousingTypeService iMainDataHousingTypeService;


    @ApiOperation(value="新增住房类型", notes="新增住房类型")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增住房类型", operDesc = "新增住房类型")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataHousingTypeAddReq req){
        Result result = iMainDataHousingTypeService.add(req,getCurrentUser(getRequest()));
        return result;
    }

    @ApiOperation(value="编辑住房类型", notes="编辑住房类型")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑住房类型", operDesc = "编辑住房类型")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataHousingTypeUpdateReq req){

        return iMainDataHousingTypeService.update(req,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="编辑住房类型状态", notes="编辑住房类型状态")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑住房类型", operDesc = "编辑住房类型")
    @PostMapping("/updateStatus")
    public Result updateStatus(@RequestBody @Valid MainDataHousingTypeUpdateStatusReq req){
        return iMainDataHousingTypeService.updateStatus(req,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="查看住房类型列表", notes="查看住房类型列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看住房类型列表", operDesc = "编辑住房类型列表")
    @PostMapping("/list")
    public Result<PageResponse<MainDataHousingTypeListDTO>> list(@RequestBody @Valid MainDataHousingTypeListReq req){
        return Result.success(iMainDataHousingTypeService.list(req));
    }

    @ApiOperation(value="查看住房类型", notes="查看住房类型")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看住房类型列表", operDesc = "编辑住房类型列表")
    @PostMapping("/query")
    public Result<MainDataHousingTypeQueryDTO> query(@RequestBody @Valid MainDataHousingTypeUpdateStatusReq req){
        return iMainDataHousingTypeService.query(req);
    }






}
